{% macro stats_panel(panel_title, icon="chart-bar") %}
    <!-- stats: {{ panel_title }} -->
    <div class="col-md-12 col-lg-6 col-xl-4 mb-4 px-2">
        <div class="card p-1 bg-light rounded border-0 h-100">
            <div class="card-body bg-light">
                <h5 class="card-title mb-3"><i class="fas fa-{{ icon }}"></i> {{ panel_title }}</h5>
                {{ caller() }}
            </div>
        </div>
    </div>
{% endmacro %}

{% macro stats_table_row(label, value, percent=False, link=None, tooltip=None) %}
    <tr>
        <td style="text-align: left; padding:5px"
                {%- if link %} onclick="location.href='{{ link }}'"{% endif -%}
                {%- if tooltip %} data-toggle="tooltip" title="{{ tooltip }}"{% endif -%}
        >
            {{ label }}
        </td>
        <td style="text-align: right; padding:5px">{{ value }}{% if percent %}%{% endif %}</td>
    </tr>
{%- endmacro %}

{% macro upload_input(key, label, dropdown=False) %}
    <div class="input-group mb-3">
        <div class="input-group-prepend">
            <label class="input-group-text upload-label" for="{{ key }}">
                {{ label }}
            </label>
        </div>

        {{ caller() }}

        {% if dropdown %}
            <div class="input-group-append">
                <button type="button" id="{{ key }}-button" class="btn btn-input-group-upload"
                        tabindex="-1" {% if key == "device_name" %}disabled{% endif %}>
                    <i class="fas fa-caret-down click-through"></i>
                </button>
            </div>
        {% endif %}
    </div>
{%- endmacro %}

{% macro fw_detail_tabular_field(firmware) %}
    <li class="list-group-item p-0 li-hover bg-light">
        <div class="clickable p-2" onclick="location.href='/analysis/{{ firmware.uid }}'">
            <a href='/analysis/{{ firmware.uid }}'>
                <div class="d-flex justify-content-between align-items-center hid">
                    {{ firmware.hid }}
                    <span>{{ firmware.tags | render_fw_tags(size=11) | safe }}</span>
                </div>
            </a>
            <div class="d-flex justify-content-between align-items-center">
                <span class="footnote text-muted">{{ firmware.submission_date | nice_unix_time | safe }}</span>
                <a href="/download/{{ firmware.uid }}" class="pull-right"><i class="fas fa-download"></i></a>
            </div>
        </div>
        {{ caller() }}
    </li>
{% endmacro %}
